// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2020, Konrad Dybcio
 */

#include "msm8994.dtsi"
#include "pm8994.dtsi"
#include "pmi8994.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/gpio-keys.h>

/ {
	/* required for bootloader to select correct board */
	qcom,msm-id = <0xcf 0x20001>;
	qcom,pmic-id = <0x10009 0x1000a 0x00 0x00>;
	qcom,board-id = <8 0>;

	/* Kitakami firmware doesn't support PSCI */
	/delete-node/ psci;

	gpio_keys {
		compatible = "gpio-keys";
		input-name = "gpio-keys";
		#address-cells = <1>;
		#size-cells = <0>;
		autorepeat;

		button@0 {
			label = "Volume Down";
			gpios = <&pm8994_gpios 2 GPIO_ACTIVE_LOW>;
			linux,input-type = <1>;
			linux,code = <KEY_VOLUMEDOWN>;
			wakeup-source;
			debounce-interval = <15>;
		};

		button@1 {
			label = "Volume Up";
			gpios = <&pm8994_gpios 3 GPIO_ACTIVE_LOW>;
			linux,input-type = <1>;
			linux,code = <KEY_VOLUMEUP>;
			wakeup-source;
			debounce-interval = <15>;
		};

		button@2 {
			label = "Camera Snapshot";
			gpios = <&pm8994_gpios 4 GPIO_ACTIVE_LOW>;
			linux,input-type = <1>;
			linux,code = <KEY_CAMERA>;
			wakeup-source;
			debounce-interval = <15>;
		};

		button@3 {
			label = "Camera Focus";
			gpios = <&pm8994_gpios 5 GPIO_ACTIVE_LOW>;
			linux,input-type = <1>;
			linux,code = <KEY_VOLUMEUP>;
			wakeup-source;
			debounce-interval = <15>;
		};
	};

	reserved-memory {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;

		/* This is for getting crash logs using Android downstream kernels */
		ramoops@1fe00000 {
			compatible = "ramoops";
			reg = <0x0 0x1fe00000 0x0 0x200000>;
			console-size = <0x100000>;
			record-size = <0x10000>;
			ftrace-size = <0x10000>;
			pmsg-size = <0x80000>;
		};

		continuous_splash: framebuffer@3401000{
			reg = <0x0 0x3401000 0x0 0x2200000>;
			no-map;
		};

		dfps_data_mem: dfps_data_mem@3400000 {
			reg = <0x0 0x3400000 0x0 0x1000>;
			no-map;
		};

		peripheral_region: peripheral_region@7400000 {
			reg = <0x0 0x7400000 0x0 0x1c00000>;
			no-map;
		};

		modem_region: modem_region@9000000 {
			reg = <0x0 0x9000000 0x0 0x5a00000>;
			no-map;
		};

		tzapp: modem_region@ea00000 {
			reg = <0x0 0xea00000 0x0 0x1900000>;
			no-map;
		};

		fb_region: fb_region@40000000 {
			reg = <0x00 0x40000000 0x00 0x1000000>;
			no-map;
		};
	};
};

&blsp_spi0 {
	status = "okay";

	/* FPC fingerprint reader */
};

/* I2C1 is disabled on this board */

&blsp_i2c2 {
	status = "okay";

	/* NXP NFC */
};

&blsp_i2c4 {
	status = "okay";

	/* Empty but active */
};

&blsp_i2c5 {
	status = "okay";

	/* SMB1357 charger and sii8620 HDMI/MHL bridge */
};

&blsp_i2c6 {
	status = "okay";

	/* Synaptics touchscreen */
};

&blsp1_uart2 {
	status = "okay";
};

&blsp2_uart2 {
	status = "okay";
};

&rpm_requests {
	pm8994_regulators: pm8994-regulators {
		compatible = "qcom,rpm-pm8994-regulators";
		vdd_l1-supply = <&pm8994_s1>;
		vdd_l2_26_28-supply = <&pm8994_s3>;
		vdd_l3_11-supply = <&pm8994_s3>;
		vdd_l4_27_31-supply = <&pm8994_s3>;
		vdd_l5_7-supply = <&pm8994_s3>;
		vdd_l6_12_32-supply = <&pm8994_s5>;
		vdd_l8_16_30-supply = <&vreg_vph_pwr>;
		vdd_l9_10_18_22-supply = <&vreg_vph_pwr>;
		vdd_l13_19_23_24-supply = <&vreg_vph_pwr>;
		vdd_l14_15-supply = <&pm8994_s5>;
		vdd_l17_29-supply = <&vreg_vph_pwr>;
		vdd_l20_21-supply = <&vreg_vph_pwr>;
		vdd_l25-supply = <&pm8994_s5>;
		vdd_lvs1_2 = <&pm8994_s4>;

		pm8994_s1: s1 {};
		pm8994_s2: s2 {};
		pm8994_s3: s3 {};
		pm8994_s4: s4 {};
		pm8994_s5: s5 {};
		pm8994_s6: s6 {};
		pm8994_s7: s7 {};

		pm8994_l1: l1 {};
		pm8994_l2: l2 {};
		pm8994_l3: l3 {};
		pm8994_l4: l4 {};
		pm8994_l6: l6 {};
		pm8994_l8: l8 {};
		pm8994_l9: l9 {};
		pm8994_l10: l10 {};
		pm8994_l11: l11 {};
		pm8994_l12: l12 {};
		pm8994_l13: l13 {};
		pm8994_l14: l14 {};
		pm8994_l15: l15 {};
		pm8994_l16: l16 {};
		pm8994_l17: l17 {};
		pm8994_l18: l18 {};
		pm8994_l19: l19 {};
		pm8994_l20: l20 {};
		pm8994_l21: l21 {};
		pm8994_l22: l22 {};
		pm8994_l23: l23 {};
		pm8994_l24: l24 {};
		pm8994_l25: l25 {};
		pm8994_l26: l26 {};
		pm8994_l27: l27 {};
		pm8994_l28: l28 {};
		pm8994_l29: l29 {};
		pm8994_l30: l30 {};
		pm8994_l31: l31 {};
		pm8994_l32: l32 {};

		pm8994_lvs1: lvs1 {};
		pm8994_lvs2: lvs2 {};
	};

	pmi8994_regulators: pmi8994-regulators {
		compatible = "qcom,rpm-pmi8994-regulators";

		pmi8994_s1: s1 {};
		pmi8994_s2: s2 {};
		pmi8994_s3: s3 {};
		pmi8994_bby: boost-bypass {};
	};
};

&sdhc1 {
	status = "okay";

	/* Downstream pushes 2.95V to the sdhci device,
	 * but upstream driver REALLY wants to make vmmc 1.8v
	 * cause of the hs400-1_8v mode. MMC works fine without
	 * that regulator, so let's not use it for now.
	 * vqmmc is also disabled cause driver stll complains.
	 *
	 * vmmc-supply = <&pm8994_l20>;
	 * vqmmc-supply = <&pm8994_s4>;
	 */
};
